package abmb.utils;

import java.util.ArrayList;
/**
 * This class is used by servlets to get the links to other servlets.
 * @author Andrea Balboni
 * @version 1.0
 */
public class PageLinks {

	public static final String getIndexLink(){
		return "index";
	}

	public static final String getSubscribeLink(){
		return "subscribe";
	}

	public static final String getSignupLink(){
		return "signup";
	}

	public static final String getLoginLink(){
		return "login";
	}

	public static final String getLogoutLink(){
		return "logout";
	}

	public static final String getSearchLink(){
		return "search";
	}
	public static final String getPostMessageLink() {
		return "postmessage";
	}	
	public static final String getShowPostLink() {
		return "showpost";
	}

	public static final String getFollowedLink() {
		return "followed";
	}
	
	public static final String getFollowLink(){
		return "follow";
	}

	public static final String getLink(String s){
		if(s.contains("index"))	return getIndexLink();
		else if (s.contains("subscribe")) return getSubscribeLink();
		else if (s.contains("signup")) return getSignupLink();
		else if (s.contains("login")) return getLoginLink();
		else if (s.contains("logout")) return getLogoutLink();
		else if (s.contains("search")) return getSearchLink();
		else if (s.contains("postmessage")) return getPostMessageLink();
		else if (s.contains("followed")) return getFollowedLink();
		else if	(s.contains("follow")) return getFollowLink();
		else if (s.contains("showpost") || s.contains("ShowPost")) return getShowPostLink();
		else return null;
	}

	public static ArrayList<String> getNavLinks(boolean loggedin){
		ArrayList<String> sNavLinks=new ArrayList<String>();
		sNavLinks.add("<a href=\""+getIndexLink()+"\">Home</a>");
		if(loggedin){
			sNavLinks.add("<a href=\""+getPostMessageLink()+"\">Post a message</a>");
			sNavLinks.add("<a href=\""+getFollowedLink()+"\">Followed</a>");
			sNavLinks.add("<a href=\""+getFollowLink()+"\">Follow</a>");
			sNavLinks.add("<a href=\""+getLogoutLink()+"\">Logout</a>");
		}
		else{
			sNavLinks.add("<a href=\""+getSignupLink()+"\">Signup</a>");
			sNavLinks.add("<a href=\""+getLoginLink()+"\">Login</a>");
		}
		return sNavLinks;
	}

	

	
}
